import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/material.dart';
import 'comment_list/comment_item.dart';

class CommentListPage extends StatefulWidget {
  @override
  _CommentListPageState createState() => _CommentListPageState();
}

class _CommentListPageState extends State<CommentListPage> {
  String chooseText = '全部';

  List<Map<String, dynamic>> category = [
    {'name': '全部', 'num': 100},
    {'name': '好评', 'num': 50},
    {'name': '中评', 'num': 10},
    {'name': '差评', 'num': 10},
  ];

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('商品评分',
          style: TextStyle(
              fontSize: 30.sp,
              fontWeight: FontWeight.bold),),
        centerTitle: true,
      ),
      body: Container(
        width: 750.w,
        decoration: BoxDecoration(
          color: Colors.white
        ),
        padding: EdgeInsets.only(left: 25.w,right: 25.w),
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Text(
                      '评分 ',
                      style: TextStyle(color: Colors.red),
                    ),
                    Icon(
                      Icons.star,
                      size: 25.sp,
                      color: Colors.red,
                    ),
                    Icon(
                      Icons.star,
                      size: 25.sp,
                      color: Colors.red,
                    ),
                    Icon(
                      Icons.star,
                      size: 25.sp,
                      color: Colors.red,
                    ),
                  ],
                ),
                Row(
                  children: [
                    Text(
                      '100.00%',
                      style: TextStyle(color: Colors.red),
                    ),
                    Text(
                      '好评率',
                      style: TextStyle(color: Colors.grey),
                    )
                  ],
                )
              ],
            ),
            SizedBox(
              height: 7,
            ),
            Row(
                children: category.map((value) {
              return Row(
                children: [
                  ChoiceChip(
                    selected: chooseText == value['name'],
                    selectedColor: Colors.red,
                    onSelected: (e) {
                      setState(() {
                        chooseText = value['name'];
                      });
                    },
                    label: Text(
                      '${value['name']}(${value['num']})',
                      style: TextStyle(color: Colors.white),
                    ),
                  ),
                  SizedBox(
                    width: 15.w,
                  ),
                ],
              );
            }).toList()),
            CommentItem()
          ],
        ),
      ),
    );
  }
}
